<template>
  <div class="right-content">
    <p class="right-content__header">通知</p>
    <div
      class="right-content__item pointer"
      v-for="item in list.slice(0, 5)"
      :key="item.id"
      @click="$router.push(`/notice/detail?id=${item.id}`)"
    >
      <div class="right-item__text">{{ item.text }}</div>
      <p class="right-item__time">{{ item.time }}</p>
    </div>
    <div class="pdl-32">
      <a-button style="width: 226px" v-if="list.length > 4" @click="$router.push('/notice/list')"
        >查看更多
      </a-button>
    </div>
  </div>
</template>

<script lang="ts">
  import { getNoticeList } from '@/api/common'
  import { defineComponent, ref, onMounted, reactive, toRefs } from 'vue'

  // import performanceMonitor from '@/utils/performanceMonitor'

  export default defineComponent({
    name: 'Welcome',
    components: {},
    setup() {
      const state = reactive({
        list: [] as any,
      })

      onMounted(async () => {
        const res = await getNoticeList({})
        console.log(res)
        state.list = res.list
      })
      // console.log(performanceMonitor.getPerformanceData(), 'performanceMonitor')

      return {
        ...toRefs(state),
      }
    },
  })
</script>

<style lang="scss" scoped>
  .right-content {
    width: 290px;
    height: 100%;
    color: #666;
    position: sticky;
    top: 0;

    .right-content__header {
      height: 66px;
      line-height: 66px;
      font-size: 18px;
      color: #333;
      padding: 0 32px;
    }

    .right-content__list {
      color: #999;
    }

    .right-content__item {
      font-size: 14px;
      height: 104px;
      padding: 16px 32px;
      &:hover {
        background-color: #f9f9f9;
      }

      .right-item__text {
        font-size: 14px;
        line-height: 22px;
        -webkit-line-clamp: 2;
        overflow: hidden;
        height: 44px;
        margin-bottom: 8px;
        text-overflow: ellipsis;
      }

      .right-item__time {
        font-size: 12px;
        color: #999;
      }
    }
  }
</style>
